﻿using Mes.Pendant.Common.DtoMapping;
using Mes.Pendant.RBACFiles;
using Mes.Pendant.UserRoleAppService.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Mes.Pendant.UserRoleAppService
{
	public class UserRoleService : ApplicationService, UserRoleIService
	{
		private readonly IRepository<UserRole, int> _userRoleRepository;

		public UserRoleService(IRepository<UserRole, int> userRoleRepository)
		{
			_userRoleRepository = userRoleRepository;
		}

		public async Task<List<UserRoleListDto>> GetRolesByUser(int userId)
		{
			var predicate = PredicateBuilder.New<UserRole>(true);
			predicate = predicate.And(m => m.UserId == userId);
			var userRoleList = await _userRoleRepository.GetListAsync(predicate);
			var userRoleDtoList = userRoleList.MapToList<UserRoleListDto>();
			return userRoleDtoList;
		}



	}
}
